package com.jijunpeng.finder.manager;

import android.app.Dialog;
import android.content.Context;

import com.afollestad.materialdialogs.MaterialDialog;

/**
 * Created by jijunpeng on 16/11/14.
 *
 * @author Ji Junpeng
 */

public class DialogManager {
    private Context context;
    private Dialog dialog;

    public DialogManager(Context context) {
        this.context = context;
    }

    public void show(String msg) {
        if (dialog != null && dialog.isShowing()) {
            dialog.dismiss();
        }
        dialog = new MaterialDialog.Builder(context)
                .title("提示")
                .content(msg)
                .cancelable(true)
                .positiveText("确定")
                .show();
    }

    public void showWait(String msg) {
        if (dialog != null && dialog.isShowing()) {
            dialog.dismiss();
        }
        dialog = new MaterialDialog.Builder(context)
                .title("请稍后")
                .content(msg)
                .cancelable(false)
                .show();
    }

    public void hide() {
        if (dialog != null && dialog.isShowing()) {
            dialog.dismiss();
        }
    }
}
